-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Refactor: Remove Avatar platform specific code #15663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor: Remove Avatar platform specific code #15663
Conversation
a267ce4 to
ec58ab9
Compare
kidroca
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some notes to aid the reviewer
package.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the complied code containing the flicker fix
After it's merged the package should be updated to point to the new version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we throw a hold on this PR until Expensify/react-native-web#15 is merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we throw a hold on this PR until Expensify/react-native-web#15 is merged?
Yes, added HOLD to the title
src/components/Avatar.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The defaultSource workaround is no longer needed.
We just pass source
src/components/Image/index.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having imageSource with undefined value initially would render no image for the first render
We don't have to use state for imageSource - it doesn't save us from re-renders, because most usages pass source like <Image soruce={{ uri: '...' }} /> (a new object created inline)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The debounce here was removed because it no longer has any effect (and was a workaround) as discussed here: #9279 (comment)
(Also it's inconsistent with the .native component where no debounce is used)
There are further changes that we can add to the Image component and I can open a follow up PR:
- remove
configureOnLoad- this was a workaround needed because at the timereact-native-webdid not provide dimension in the originalonLoadcallback - Turn
Imageinto a functional component - no lifecycle and state are used.
I do both of this changes here:
but the PR is on hold
Reviewer Checklist
Screenshots/VideosWeb15663.Web.mov15663.Web.2.mp4Mobile Web - Chrome15663.mWeb-Chrome.mp4Mobile Web - Safari15663.mWeb.Safari.mp415663.mWeb-Safari.2.mp4Desktop15663.Desktop.mp4iOS15663.iOS.2.mp4Android15663.Android.mp415663.iOS.mp4 |
mollfpr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work on this @kidroca! Looks good to me and tests well 👍
|
Thanks @mollfpr BTW no one is assigned to review it Current PR servers to verify the fix is working in App, but it has to wait for the actual fix to be released in |
bondydaa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 looks good, I'll approve once we've gotten the react-native-web PR merged and the package.json updated with the correct version number.
mountiny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going to try to release the new version of our fork, @kidroca can you resolve the merge conflicts in the meantime, thanks!
I don't see the new |
e335e60 to
33560af
Compare
|
@kidroca should be released in version |
33560af to
d3a0794
Compare
d3a0794 to
c4abb46
Compare
|
Updated to latest @bondydaa you approved this PR before but there's a change that I had to make: https://github.com/Expensify/App/pull/15663/files#r1144494327 ✅ Ready for Review |
Screenshots/VideosWeb15663.Web.mp4Mobile Web - Chrome15663.mWeb-Chrome.mp4Mobile Web - Safari15663.mWeb-Safari.mp4Desktop15663.Desktop.mp4iOS15663.iOS.mp4Android15663.Android.mp4 |
mollfpr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test well 👍
mountiny
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 1.2.89-0 🚀
|
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.2.89-0 🚀
|
Details
The avatar component uses a workaround to prevent a flicker bug in react-native-web
We submitted a fix for react-native-web and the workaround is no longer needed
Why was the Image component updated
The code contributed to the flicker because the
imageSourcestarts withundefinedand is only updated after mount - this causes the first render pass to show no image (this happens very quickly, but sometimes a flicker can be seen)Fixed Issues
$ #14278
PROPOSAL: #9183 (comment)
FORK PR: Expensify/react-native-web#15
Tests
There should be no flicker
Image
onLoadwas slightly changed, it should not cause a regressionOffline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
Screen.Recording.2023-03-04.at.19.48.03.mov
Mobile Web - Chrome
Android.Emulator.-.Pixel_2_API_29_5554.2023-03-06.15-35-04.mp4
Mobile Web - Safari
Desktop
Screen.Recording.2023-03-04.at.20.40.49.mov
iOS
Simulator.Screen.Recording.-.iPhone.14.-.2023-03-04.at.20.47.43.mp4
Android
Android.Emulator.-.Pixel_2_API_29_5554.2023-03-06.15-30-22.mp4